import axios from 'axios'
// var qs = require('qs')
const host = window.host
const discount = 'thishop-coupon'
// 创建优惠券
export function createDiscount (data) {
  const url = `${host}/${discount}/coupon/create`
  return axios.post(url, data)
    .then(res => {
      return Promise.resolve(res.data)
    })
}
// 获取优惠券列表
export function getDiscountList (data) {
  const url = `${host}/${discount}/coupon/query`
  return axios.post(url, data)
    .then(res => {
      return Promise.resolve(res.data)
    })
}
// 获取优惠券状态
export function setDiscountState (couponTypeId, typeStatus) {
  const url = `${host}/${discount}/coupon/${couponTypeId}/enable`
  return axios.post(url, {typeStatus})
    .then(res => {
      return Promise.resolve(res.data)
    })
}
// 获取优惠券状态
export function getDiscountDetail (ids) {
  const url = `${host}/${discount}/coupon/queryByIds`
  return axios.post(url, {ids})
    .then(res => {
      return Promise.resolve(res.data)
    })
}
// 获取优惠券状态
export function editDiscountDetail (couponTypeId, data) {
  const url = `${host}/${discount}/coupon/${couponTypeId}/update`
  return axios.post(url, data)
    .then(res => {
      return Promise.resolve(res.data)
    })
}
